#!/bin/bash
#-----------------------------------------------------------
#                COLOUR VARIABLES
#-----------------------------------------------------------
UNDL="\033[4m"    F6_E="\033[0m"    B_WT="\033[47m"
F_BL="\033[30m"   F_RD="\033[31m"   F_GR="\033[32m"
F_YL="\033[33m"   F_BU="\033[34m"   F_PU="\033[35m"
F_DG="\033[36m"   F_WT="\033[37m"   B_BL="\033[40m"
B_RE="\033[41m"   B_GR="\033[42m"   B_YL="\033[43m"
B_BU="\033[44m"   B_PR="\033[45m"   B_DG="\033[46m"

#-----------------------------------------------------------
#                  MAIN PROCESS
#-----------------------------------------------------------
# Copyright (C) 2010-2011 Cameo Communications, Inc.
############################################################################ ##

# 1. link vimrc
if [ -s ~/.vimrc ]; then
    mv ~/.vimrc ~/.vimrc_bp_1
    rm -rf .vimrc
fi

ln -s $(pwd)/vimrc  ~/.vimrc
if [[ $? != "0" ]];then
    echo -e "$F_YL link vimrc failed ! $F6_E \n"
fi

# 2. link .vim
if [[ -d ~/.vim || -L ~/.vim ]];then
    mv ~/.vim  ~/.vimbp_1
    rm -rf ~/.vim
fi
ln -s $(pwd)/vim  ~/.vim
if [[ $? != "0" ]];then
    echo -e "$F_YL link .vim/ failed ! $F6_E \n"
fi
MY_COLOR=`find -name mycolor.vim`
if [[ $? == "0" ]];then
    sudo cp -r ${MY_COLOR} /usr/share/vim/vim82/colors/
fi
git clone https://gitee.com/yanzhongqian/vim-plug.git ~/.vim/autoload
# 3. auto install Various plugins
vim -c "PlugInstall" -c "q" -c "q"
vim -c "LeaderfInstallCExtension" -c "q" -c "q"
